package thread;

public class Demo12 {
    public static void main3(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
            while (true){
                try {
                    Thread.sleep(2000);
                }catch (InterruptedException e){
                    throw  new RuntimeException(e);
                }
            }
        });
        System.out.println(t.getState());
        t.start();
        Thread.sleep(1000);
        System.out.println(t.getState());
    }
    public static void main2(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
            System.out.println("Hello thread");
        });
        System.out.println(t.getState());//NEW 安排了⼯作, 还未开始⾏动
        t.start();
        System.out.println(t.getState());
        Thread.sleep(1000);
        System.out.println(t.getState());//TERMINATED 工作完成了
    }
        public static void main1(String[] args) {
            //线程状态
            for (Thread.State state : Thread.State.values()) {
                System.out.println(state);
            }
        }
}
